<?php

namespace App\HttpController;

use App\Service\ReportService;
use EasySwoole\HttpAnnotation\AnnotationTag\Api;
use EasySwoole\HttpAnnotation\AnnotationTag\ApiDescription;
use EasySwoole\HttpAnnotation\AnnotationTag\ApiGroup;
use EasySwoole\HttpAnnotation\AnnotationTag\Method;
use EasySwoole\HttpAnnotation\AnnotationTag\Param;
use EasySwoole\ORM\Exception\Exception;
use Throwable;

/**
 * @ApiGroup(groupName="用户反馈")
 */
class Report extends BaseController
{
    /**
     * @ApiDescription(value="用户反馈")
     * @Api(name="用户反馈", path="/report/report", version="1.0.0")
     * @Method(allow={POST})
     * @Param(name="content", description="举报内容", required="", notEmpty="举报内容不能为空", from={JSON})
     * @Param(name="images", description="举报图片", required="", from={JSON})
     * @return bool
     * @throws Exception
     * @throws Throwable
     */
    public function report($content, $images): bool
    {
        $res = ReportService::getInstance()->report($this->uid, $content, $images);
        if (!$res['result']) {
            return $this->writeJsonError($res['msg']);
        }
        return $this->writeJsonSuccess($res['data'], $res['msg']);
    }
}